<template>
	<view class="mainpadding" style="padding-bottom: 150rpx;">
		<view class="mainpadding ffffff radius">
			<view class="flexbetween">
				<view class="">
					<text class="bigtext xiaohei fonweight">{{convertDate(currentdate)}}（{{getCurrentDayOfWeek(currentdate)}}）{{sendtime}}</text>
					<text class="ershiba xiaohui margin_left1">出发</text>
				</view>
				<text class="bigtext xiaolan fonweight"><text class="smalltext xiaolan">￥</text>{{dataAll.tourist.price}}</text>
			</view>
			<view class="flexleft margin_top xiaohui ershiba" @click="callphone(dataAll.tel)">
				<u-icon name="phone-fill" color="#2979ff" size="14"></u-icon>
				<view class="xiaolan">随车电话</view>
			</view>
		</view>
		<view class="mainpadding_top radius" style="background-color: #eff6ff;">
			<view class="xiaohei fonweight bigtext">选择上车点</view>
			<view class="flexleft xiahuaxian margin_top" v-for="item in dataAll.touristsite_start" :key="item.id" @click="startId=item.id;sendtime=item.tourist_site_time;">
				<view class="margin_right1" v-if="item.id==startId">
					<u-icon name="checkmark-circle-fill" color="#2979ff" size="16"></u-icon>
				</view>
				<view class="weixz margin_right1" v-if="item.id!=startId"></view>
				<view class="yhxk ershiba " :class="item.id==startId?'xiaolan':'xiaohei'" style="width: 550rpx;">{{item.tourist_site_time}}  {{item.address_name}}</view>
			</view>
		</view>
		<view class="mainpadding_top radius" style="background-color: #fff8f2;">
			<view class="xiaohei fonweight bigtext">选择下车点</view>
			<view class="flexleft xiahuaxian margin_top" v-for="item in dataAll.touristsite_end" :key="item.id" @click="endId=item.id">
				<view class="margin_right1" v-if="item.id==endId">
					<u-icon name="checkmark-circle-fill" color="#f37b1d" size="16"></u-icon>
				</view>
				<view class="weixz margin_right1" v-if="item.id!=endId"></view>
				<view class="yhxk ershiba " :class="item.id==endId?'xiaohuang':'xiaohei'" style="width: 550rpx;">{{item.tourist_site_time}}  {{item.address_name}}</view>
			</view>
		</view>
		<view class="gudingdb mainpadding flexbetween ffffff">
			<view class="flexleft titletext bold">
				<view class="xiaohei">票价：</view>
				<view class="xiaolan fonweight">￥{{dataAll.tourist.price}}</view>
			</view>
			<view class="bigbtn" style="width: 35%;border-radius: 50rpx;" @click="submit()">下一步</view>
		</view>
	</view>
</template>
<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				listid:{},
				currentdate:"",
				currenttime:"",
				dataAll:{},
				startId:"",
				endId:"",
				sendtime:""
			}
		},
		onLoad(options) {
			this.listid = options.id
			this.currentdate = options.currentdate
			this.getdetail()
		},
		methods: {
			getdetail(){
				httpRequest.request('/api/Travelcl/touristTimeDetail','GET',{
					 id:this.listid
				}).then(res => {
					this.dataAll = res.data
				})
			},
			submit(){
				if(this.startId==""){
					httpRequest.toast("请选择上车点")
					return false
				}
				if(this.endId==""){
					httpRequest.toast("请选择下车点")
					return false
				}
				let data = {
					tourist_time_id:this.listid,
					startId:this.startId,
					endId:this.endId,
					tourist_id:this.dataAll.tourist.id,
					currentdate:this.currentdate,
					sendtime:this.sendtime
				}
				uni.redirectTo({
					url:"/pages/index/querendd?msg=" + encodeURIComponent(JSON.stringify(data))
				})
			},
			// yyyy-mm-dd转换mm/dd
			convertDate(dateString) {
				const parts = dateString.split('-');
				const year = parts[0]; // 不需要转换
				const month = parts[1]; // 需要转换为 mm/dd 格式
				const day = parts[2]; // 需要转换为 mm/dd 格式
				// 使用两位数表示月份和日期
				return `${month.padStart(2, '0')}月${day.padStart(2, '0')}日`;
			},
			// 年月日转换周几
			getCurrentDayOfWeek(val) {
				const today = new Date(val);
				const dayOfWeek = today.getDay();
				const daysOfWeek = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
				return daysOfWeek[dayOfWeek];
			}
		}
	}
</script>

<style>

</style>
